package com.example.file.security.auth;


import com.example.file.security.User;
import com.example.file.security.support.JwtVerifyHandler;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import reactor.core.publisher.Mono;

import java.util.Collections;

/**
 * CurrentUserAuthenticationBearer class
 *
 * @author Erik Amaru Ortiz
 */
public class CurrentUserAuthenticationBearer {
    public static Mono<Authentication> create(JwtVerifyHandler.VerificationResult verificationResult) {

        if (verificationResult == null || verificationResult.claims == null) {
            return Mono.empty();
        }

        User user = new User();


//        var principal = new UserPrincipal(principalId, claims.getIssuer());

        return Mono.justOrEmpty(new UsernamePasswordAuthenticationToken(user, verificationResult.token, Collections.emptyList()));
    }

}
